<template>
  <div class="captcha-btn">
    <a-input placeholder="请输入密码" />
    <a-button
      :disabled="btnState.smsSendBtn"
      @click.stop.prevent="getCaptcha"
      v-text="!btnState.smsSendBtn ? '获取' : btnState.time + ' s'"
    />
  </div>
</template>

<script lang="ts" setup>
import { reactive } from 'vue';
type Props = {
  phone: string;
};

const props = defineProps<Props>();
const emits = defineEmits<{
  (event: 'getPhoneNum', done: (avaliable: boolean) => void): void;
}>();

const btnState = reactive({ smsSendBtn: false, time: 60 });

async function getCaptcha() {
  emits('getPhoneNum', avaliable => {
    console.log(avaliable);
    console.log(props.phone);
  });
}
</script>

<style lang="scss" scoped>
.captcha-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  :deep(.ant-input) {
    width: 226px;
  }
  :deep(.ant-btn) {
    width: 130px;
    height: 52px;
    border: 1px solid #1890ff;
    border-radius: 4px;
    box-sizing: border-box;

    font-size: 14px;
    font-family: Adobe Heiti Std;
    font-weight: normal;
    color: #1890ff;
  }
}
</style>
